
--[[
title: 工具函数
description: 常用函数封装
]]

-- 全局函数
local _G_type = _G.type;


function commonlib.nullfunc()
end

-- 三目运算
function commonlib.if_else(b, t, f)
    if (b) then
        return t;
    else
        return f;
    end
end

function commonlib.bind(self, func)
    return function(...) return func(self, ...) end
end

function commonlib.IsNil(value)
    return value == nil;
end

function commonlib.IsBoolean(value)
    return _G_type(value) == "boolean";
end

function commonlib.IsNumber(value)
    return _G_type(value) == "number";
end

function commonlib.IsString(value)
    return _G_type(value) == "string";
end

function commonlib.IsTable(value)
    return _G_type(value) == "table";
end

function commonlib.IsFunction(value)
    return _G_type(value) == "function";
end

local __platform__ = commonlib.GetPlatform();
function commonlib.IsWindowPlatform()
    return commonlib.IPlatform_WINDOW == __platform__;
end
function commonlib.IsLinuxPlatform()
    return commonlib.IPlatform_LINUX == __platform__;
end
function commonlib.IsEmscriptenPlatform()
    return commonlib.IPlatform_EMSCRIPTEN == __platform__;
end
